#pragma once
template <class iterator, class Ref, class Ptr>
class Reverse_iterator{
   iterator _it;
public:
   Reverse_iterator(const iterator &it)
     :_it(it)
   {}

   Ref operator*() const{
     iterator tmp = _it;
     return *--tmp;
   }
   
   Ptr operator->() const{
     return &(operator*());
   }

   Reverse_iterator& operator++(){
      --_it;
      return *this;
   }

   Reverse_iterator& operator--(){
     ++_it;
     return *this;
   }

   Reverse_iterator operator++(int){
     Reverse_iterator tmp(*this);
      --_it;
      return tmp;
   }

   Reverse_iterator operator--(int){
     Reverse_iterator tmp(*this);
     ++_it;
     return tmp;
   }

   bool operator!=(const Reverse_iterator &rit) const {
     return _it != rit._it; 
   }

   bool operator==(const Reverse_iterator &rit) const {
     return _it == rit._it; 
   }
};
